﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;

using ProjectBase.Core;
using ProjectBase.Core.Web;

namespace ProjectBase.Mvc.Models
{
    /// <summary>
    ///     The accurate list of datasources needed for MasterPage
    /// </summary>
    public class MasterModel : CoreModel, IMasterModel
    {
        #region members
        string _actionDescription;
        IButtonItem _buttonSubmit;
        #endregion members

        /// <summary>
        ///     DataSource for ButtonsWC.ascx
        /// </summary>
        public virtual IButtonsModel ButtonsModel { get; set; }

        /// <summary>
        ///     DataSource for ActionsWC.ascx
        /// </summary>
        public virtual IActionsModel ActionsModel { get; set; }

        #region IMasterModel
        /// <summary>
        ///     The central button of application connected to the From id="Constants.WebControls.MainFormId".
        ///     This main Form 'action' attribute is filled with the ButtonSubmit settings
        /// </summary>
        public virtual IButtonItem ButtonSubmit
        {
            get { return _buttonSubmit; }
            set
            {
                _buttonSubmit = value;
                if (_buttonSubmit.Is())
                {
                    _buttonSubmit.FormIdForJS = Constants.WebControls.MainFormId;
                }
            }
        }

        /// <summary>
        ///     Current Controller name
        /// </summary>
        public virtual string ControllerName { get; set; }

        /// <summary>
        ///     Current Action name of current Controller
        /// </summary>
        public virtual string CurrentAction { get; set; }

        /// <summary>
        ///     Keeps the value of currently used MasterPage.
        ///     e.g. 'mv' for default master view;
        /// </summary>
        public virtual string CurrentMasterPageValue { get; set; }

        /// <summary>
        ///     Provides the BreadCrumb control description.
        ///     if null nor empty, CurrentAction should be used.
        /// </summary>
        public virtual string ActionDescription
        {
            get
            {
                return _actionDescription.IsEmpty() ? CurrentAction : _actionDescription;
            }
            set { _actionDescription = value; }
        }

        /// <summary>
        ///     Item Description allowes you to append some information
        ///     for Bread-Crumb control - about currently executed Action
        /// </summary>
        public virtual string ItemDescription { get; set; }

        /// <summary>
        ///     Common switch to inform, that Application is in Read-Only mode
        /// </summary>
        public virtual bool IsReadOnly { get; set; }

        #endregion IMasterModel
    }
}